package com.example.controller;

import com.example.entity.CommonReqDTO;
import com.example.entity.Result;
import com.example.service.ComponentTemplateInstService;
import com.example.service.DataService;
import com.example.service.HealthService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@Api(value = "健康度评估模板", description = "健康度评估模板")
@RestController
@RequestMapping(value = "/api/health", produces = MediaType.APPLICATION_JSON_VALUE)
public class HealthController {

    @Autowired
    private HealthService healthService;


    @Autowired
    private DataService dataServcie;

    @Autowired
    private ComponentTemplateInstService componentTemplateInstService;




    @ApiOperation(value = "添加参数的动态sql")
    @PostMapping("/getHealthInfo/{instId}")
    public Result create(@PathVariable("id") Long instId,   @RequestBody CommonReqDTO reqDTO) {

        List<Map<String, Object>> list=  healthService.getConfigData( instId, reqDTO);

        return Result.success(list);
    }



    @GetMapping("/templateInstanceId/{id}")
    public ResponseEntity<Object> getByPageTemplateId(@PathVariable Long id) {
        /**
         * {
         * 商品维度：
         * "goods_way":
         * [{},{},{},{}],
         *
         * 运营维度：
         * "operation_way":
         * [{},{},{},{}],
         *
         * 供应链维度：
         * "supply_chain_way":
         * [{},{},{},{}],
         *
         * 财务维度：
         * "finance_way":
         * [{},{},{},{}],
         *
         * 顾客维度：
         * "customer_way":
         * [{},{},{},{}],
         * }
         */



        //从数据库中获取商品维度的信息并计算
        String rs = "{" +

                "\"goods_way\":" +
                "[{\"ab_product_shortage\":\"17%\",\"cssColor\":\"red\"}]," +

                "\"operation_way\":" +
                "[{\"promotion_product_rate\":\"17%\",\"cssColor\":\"red\"}]," +

                "\"supply_chain_way\":" +
                "[{\"order_fulfillment_rate\":\"17%\",\"cssColor\":\"red\"}]," +

                "\"finance_way\":" +
                "[{\"loss_interest_product_rate\":\"17%\",\"cssColor\":\"red\"}]," +

                "\"customer_way\":" +
                "[{\"complaint_rate\":\"17%\",\"cssColor\":\"red\"}]," +
                "}";



        return null;


    }



}

